{template 'common/header'}
<ul class="nav nav-tabs">    
    <li ><a href="{php echo $this->createWebUrl('setclass');}">分类列表</a></li>
</ul> 
<div class="panel panel-warning">
  <div class="panel-heading">增加分类</div>
  <div class="panel-body">
  	<div class="form-horizontal">
		<div class="form-group">
	    	<label class="col-sm-2 control-label">分类名称</label>
		    <div class="col-sm-8">
		      	<input class="form-control required" type="text" id="name" name="name" placeholder="请填写分类名称" value="">
		    </div>
	  	</div>
    <div class="form-group">
        <label class="col-sm-2 control-label">背景颜色</label>
        <div class="col-sm-8">
            {php echo tpl_form_field_color('bg_color', $class['bg_color']);}
        </div>
      </div>        
		<div class="form-group">
	    	<label class="col-sm-2 control-label">排序顺序</label>
		    <div class="col-sm-8">
		      	<input class="form-control required" type="number" id="order" name="order" placeholder="请填写排序值越大越靠前" value="">
		    </div>
	  </div>
	  	<div class="form-group">
		  	<div class="col-sm-offset-2 col-sm-10">
				 <input type="submit" id="submit" name="submit" class="btn btn-info" value="确认提交">
			</div>
	  	</div>
	  </div>
	</div>  	 	
  </div>	
</div>  
<style type="text/css">.right-content{padding: 0;}</style>
<link rel="stylesheet" href="{MODULE_URL}public/css/Toast.css">
<script src="{MODULE_URL}public/js/Toast.js"></script>  
<script>
$(document).ready(function(){
       $("#submit").on(
            "click",function(){
            	var categoryname = $.trim($('#name').val());
            	var category_order = $.trim($('#order').val());
              var bg_color = $.trim($('input[name="bg_color"]').val());
                 $.ajax({
                     url:"{php echo $this->createWebUrl('save_classadd');}&version_id="+"{$_GPC['version_id']}",
                     data:{categoryname:categoryname,category_order:category_order,bg_color:bg_color},
                     dataType:"json",
                     type:"post",
                    success:function(res){
                       if(res.status== 1){
						          mqToast({type:1,context: res.msg}); 
                      setTimeout(function(){
                        window.location.reload();
                      },2000);  
                      return false;
                       }else{
                           mqToast({type:1,context: res.msg}); 
                           return false;
                       }
                    }
                })
        })

});

</script>